var ChatImageMsg = (function(){
    
    var _imgMsgTmp = [
        '<div>',
            '<img class="imgMsg" src="<%= o.img %>" width="<%= o.width %>" height="<%= o.height %>" original-src="<%= o.originalImg %>" style="cursor:pointer;" />',
        '</div>'
    ].join('');
    
    var _chatImageMsg = (function ChatImageMsg(){        
    }).extend(ChatMsg, 'ChatImageMsg');
    
    _chatImageMsg.prototype._init = function(){
        
        //限制宽高.
        if(this.msg['big']){
            this.msg['width'] = this.msg['big'][0];
            this.msg['height'] = this.msg['big'][1];
            Size.constraint(this.msg, 500, 500);
        } else {
            this.msg['width'] = 'auto';
            this.msg['height'] = 'auto';
        }
        
        var $image = $(tmpl(_imgMsgTmp, this.msg));        
        this.$wrapper.find('.chatMsgItemContent').prepend($image);
        
        this.on('showProgressBar', function(){
            this.$sendProgressBar.progressBar({
                theme : 'imgMsgBar'
            });        
            this.progressBar = this.$sendProgressBar.data('progressBar');    
        });
                
        $image.find('.imgMsg').on('click', function(){            
            ujs.ui.Dialog.get(ujs.subjects.dialog.ImagePreviewDialog, {                
                image : $(this).attr('original-src')
            });            
        });
    };
    
    return _chatImageMsg;
})();